Learn R Programming

collapse (version 1.5.0)

is.regular, is.unlistable: Regular Objects and Unlistable Lists

Description

In collapse a regular R object is defined as an R object that is either atomic or a list - checked with is.regular. A (nested) list composed of regular objects at each level is unlistable - checked with is.unlistable.

Usage

is.regular(x)
is.unlistable(l, DF.as.list = FALSE)

Arguments

x

an R object.

l

a list.

DF.as.list

logical. TRUE treats data frames like (sub-)lists; FALSE like atomic elements.

Value

logical(1) - TRUE or FALSE.

Details

is.regular is simply defined as is.atomic(x) || is.list(x). is.unlistable with DF.as.list = TRUE is defined as all(rapply(l, is.atomic)), whereas DF.as.list = FALSE yields checking using all(unlist(rapply2d(l, is.regular), use.names = FALSE)). If l contains data frames, the latter can be a lot faster than applying is.atomic to every data frame column.

See Also

ldepth, has_elem, List Processing, Collapse Overview

Examples

Run this code
# NOT RUN {
is.regular(list(1,2))
is.regular(2)
is.regular(a ~ c)
l <- list(1, 2, list(3, 4, "b", FALSE))
is.regular(l)
is.unlistable(l)
l <- list(1, 2, list(3, 4, "b", FALSE, e ~ b))
is.regular(l)
is.unlistable(l)

# }

Run the code above in your browser using DataLab